package com.zy1;

import com.zy1.mapper.Usermapper;
import com.zy1.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession session = sqlSessionFactory.openSession();
        Usermapper usermapper=session.getMapper(Usermapper.class);
        List<User> users=usermapper.selectUser();
        usermapper.xxxx("1","1",2);
        usermapper.update("1","1",2);
        User user1=usermapper.login("admin","123456");
        User userx=usermapper.sss(1);
        usermapper.insert("1","1","1@qq.com");
        usermapper.delete(2);
        session.commit();
        System.out.println(userx);
        System.out.println(user1);
        System.out.println(users);
    }
}